'use strict';

const Controller = require('egg').Controller;

class UserLoginController extends Controller {
  async index() {
    const { ctx } = this;
    var {userName , pwd} = ctx.request.body
    var db = this.app.mongodb
    var res =await db.collection("user").find({userName,pwd}).toArray();
    if (res.length) {
      ctx.body = {
        res:true,
        msg:'登录成功'
      }
    }else{
      ctx.body = {
        res:false,
        msg:'用户名或密码错误'
      }
    }
  }
}

module.exports = UserLoginController;
